#pragma once
#include"BoostHTTP.h"
namespace maxc
{
	namespace down
	{
		class Download :private HTTP
		{
		protected:
			using strHeaderPair = header::HTTPRequestHeader::strHeaderMarkPair;
		public:
			Download(maxc::_asio::io_service& ios);
			Download(maxc::_asio::io_service& ios,unsigned int st, unsigned int ed);
			
			Download& SetRanges(unsigned int start, unsigned int end);
			Download& SetCookie(std::string cookie);
			Download& ResetFilePath(const char * filepath);
			~Download() { file.close(); }
			void StartDownload();
			void MTDownload();
			//void RBDownload();
			void StartDownloadMT();
			void WriteToFileMT();
			unsigned int GetFileSize();
			Download(Download&) = delete;
			void operator=(Download&) = delete;
		private:
			void FileAlloc();
			std::ofstream file;
			header::HTTPRequestHeader httpReqHeader;
			maxc::_asio::io_service& ios;
		public:
			unsigned int partStart;
			unsigned int partEnd;
		/*private:
			std::list<unsigned int> partSTs;
			std::list<unsigned int> remainPartSTs;*/
		};
	}
}